<?php

class Wakwww extends WakEngineKit {

    function _setUp() {
        // i18n
        $this->response->chooseLangFrom(array('fr'),'fr');
        $this->templates->setCriteria('lang',$this->response->lang);
        // print_r($this->response);

        return true;
    }

    function tutorial($id=null) {
        $this->response->addBreadCrumb('Accueil', $this->response->request->getBaseHref());
        $this->response->addBreadCrumb('Tutoriel', 'tutorial');
        if ($id)
            $this->response->addBreadCrumb($id, $id);
        $this->_fallbackController();
    }

    public function howto($id=null) {
        $this->response->addBreadCrumb('Accueil', $this->response->request->getBaseHref());
        $this->response->addBreadCrumb('Documentation', 'howto');
        $this->response->addBreadCrumb($id, $id);
        $this->_fallbackController();
    }

    /**
     * fallback controller
     */
    function _fallbackController() {
        // defining view
        $view=str_replace('/','.',$this->response->url->getPath());
        if ($view=='')
            $view='index';
        // checking for template
        if (!$this->templates->has($view)) {
            // no template => 404
            throw new WakEngineErrorPage("no page for $view",404);
            return false;
        }
        // echo "<p>view $view</p>";
        $this->response->view=$view;
        return true;
    }/**/
}